using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace SwaggerDoc.Api.Controllers.V1
{
    /// <summary>
    /// 天气控制器
    /// </summary>
    [ApiController]
    [Route("api/[controller]/[action]")]
    [ApiVersion("1.0")]
    [Authorize]
    public class WeatherForecastController : ControllerBase
    {
        private static readonly string[] Summaries = new[]
        {
        "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
    };

        private readonly ILogger<WeatherForecastController> _logger;

        public WeatherForecastController(ILogger<WeatherForecastController> logger)
        {
            _logger = logger;
        }

       

        /// <summary>
        /// 获取天气列表V1
        /// </summary>
        /// <returns></returns>
        [HttpGet(Name = "GetWeatherForecast")]
        public IEnumerable<WeatherForecastDTO> Get()
        {
            return Enumerable.Range(1, 5).Select(index => new WeatherForecastDTO
            {
                DateTime = DateTime.Now.AddDays(index),
                Summary = Summaries[Random.Shared.Next(Summaries.Length)]
            })
            .ToArray();
        }

        /// <summary>
        /// 获取天气结果返回
        /// </summary>
        /// <returns></returns>
        [HttpGet(Name = "Result")]
        [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(WeatherForecastDTO))]
        [ProducesResponseType(StatusCodes.Status404NotFound)]
        public IActionResult Result()
        {
            return Ok(new WeatherForecastDTO());
        }

        /// <summary>
        /// 获取天气类型返回
        /// </summary>
        /// <returns></returns>
        [HttpGet(Name = "Type")]
        [ProducesResponseType(StatusCodes.Status200OK)]
        [ProducesResponseType(StatusCodes.Status404NotFound)]
        public WeatherForecastDTO Type()
        {
            return new WeatherForecastDTO();
        }


        /// <summary>
        /// 创建订单V1
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost(Name = "CreateOrder")]
        [ProducesResponseType(StatusCodes.Status201Created)]
        [ProducesResponseType(StatusCodes.Status400BadRequest)]
        public IActionResult CreateOrder([FromBody] OrderRequest request)
        {
            return Ok();
        }



    }
}